package com.mobile.model;

import org.acegisecurity.ConfigAttributeDefinition;
import org.acegisecurity.SecurityConfig;
import org.springframework.util.StringUtils;

/**
 * SysWebresPermission entity.
 * 
 * @author MyEclipse Persistence Tools
 */

public class SysWebresPermission implements java.io.Serializable {

	// Fields

	private String uniqueCode;
	private String url;
	private String roles;
	//要求权限
	private ConfigAttributeDefinition cad;

	// Constructors

	public SysWebresPermission(String uniqueCode, String url, String roles,
			ConfigAttributeDefinition cad) {
		super();
		this.uniqueCode = uniqueCode;
		this.url = url;
		this.roles = roles;
		this.cad = cad;
	}

	public ConfigAttributeDefinition getCad() {
		return cad;
	}

	public void setCad(ConfigAttributeDefinition cad) {
		this.cad = cad;
	}

	/** default constructor */
	public SysWebresPermission() {
	}

	/** full constructor */
	

	// Property accessors

	public String getUniqueCode() {
		return this.uniqueCode;
	}

	public void setUniqueCode(String uniqueCode) {
		this.uniqueCode = uniqueCode;
	}

	public String getUrl() {
		return this.url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getRoles() {
		return this.roles;
	}

	public void setRoles(String roles) {
		this.roles = roles;
		ConfigAttributeDefinition cad = new ConfigAttributeDefinition();
		String[] tokens = StringUtils.commaDelimitedListToStringArray(roles);
		for(String token : tokens){
			cad.addConfigAttribute(new SecurityConfig(token));
		}
		this.setCad(cad);
	}

}